<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }

    #dv {
      width: 200px;
      height: 200px;
      background-color: hotpink;
    }
  </style>
</head>

<body>
  <!--
    回调函数(回头调用这个函数)
      element.onclick= function(){};
      element.addEventListener("callbck",fn);
  -->
  <div id="dv">

  </div>
  <input type="button" value="点击" id="btn">
  <script>
    document.getElementById("btn").addEventListener("click", () => {
      let setId = window.setTimeout(() => {
        document.getElementById("dv").style.display = "none";
      }, 500);
    });
  </script>
</body>

</html>